<template>
    <view class="u-page" style="background-color: #ffffff;">
      <view style="padding: 1vw">
        <view class="search-bar">
          <up-form>
          <up-form-item
              label="通知标题："
              labelWidth="auto">
          </up-form-item>
            <up-input label="姓名" v-model="search.noticeTitle" placeholder="请输入标题"/>
          <up-button type="primary" style="width: 70%" @click="toSearch">查询</up-button>
          <up-button type="primary" style="margin-top: 2vh;width: 70%" @click="toReset">重置</up-button>
          </up-form>
        </view>
      </view>
      <view class="list-container">
<!--        <scroll-view-->
<!--            refresher-enabled-->
<!--            @refresherrefresh="pullDownList"-->
<!--            :refresher-triggered="triggered"-->
<!--            @scrolltolower="scrolltolowerGetList"-->
<!--            scroll-y="true"-->
<!--            style="height: 99vh"-->
<!--        >-->
        <scroll-view
            refresher-enabled
            @refresherrefresh="pullDownList"
            :refresher-triggered="triggered"
        >
          <up-list>
            <up-list-item
                v-for="(item, index) in listData"
                :key="index">
              <up-swipe-action>
                <up-swipe-action-item
                    :options="options1"
                    @click="handleButtonClick1(item)"
                    :autoClose="true"
                >
              <up-cell :title="item.noticeTitle">
              </up-cell>
                </up-swipe-action-item>
              </up-swipe-action>
            </up-list-item>
<!--            <up-loadmore :status="loadmoreStatus" @loadmore="scrolltolowerGetList" loadmoreText="点击加载更多"/>-->
          </up-list>
        </scroll-view>
      </view>
    </view>
</template>

<script setup>
import { ref } from 'vue';
import { getAllNoticList } from '@/api/system/sysIndex.js'
const listData = ref([]) // 存储分页数据
const search = ref({
  pageNum:1,
  pageSize:100,
  noticeTitle:''
})
const options1 = ref([{
  text: '查看',
  style:{
    backgroundColor:'#3c9cff'
  }
}]);
const loadmoreStatus = ref('loadmore')
//查询
function toSearch(){
  pullDownList()
}
//重置
function toReset(){
  search.value = {
    pageNum:1,
    pageSize:100,
    noticeTitle:'',
  }
  pullDownList()
}

//下拉刷新
const triggered=ref(false)
function pullDownList(){
  triggered.value = true
  getNoticeList()
}

//查看详情
function handleButtonClick1(item) {
  uni.navigateTo({
    url: `/pages/laboratory/noticeDetail?noticeTitle=${item.noticeTitle}&noticeContent=${item.noticeContent}`
  });
}
// //查询通知列表
function getNoticeList(){
  search.value.pageNum = 1
  loadmoreStatus.value = 'loadmore'
  // 模拟请求后端接口获取分页数据
  getAllNoticList(search.value).then((response) => {
    listData.value = response.rows || [];
    setTimeout(()=>{
      triggered.value = false
    },1000)
  });
}
//设置高度
const swiperHeight = ref(1000)

getNoticeList()
</script>

<style lang="scss" scoped>

</style>
